<template>
	<view>
		<custom-navbar title="意见建议、建言献策"></custom-navbar>
		<view :style="'padding-bottom: 200rpx;padding-top:'+barHeight+'px'">
<!-- 			<view style="margin-bottom: 30rpx;">
				<v-tabs :fixed="true" :zIndex='9' :scroll="false" color="#333333" activeColor="#CF1A09"
					lineHeight="5rpx" lineColor="#CF1A09" v-model="current" :tabs="tabs" @change="changeTab"></v-tabs>
			</view> -->
			<navigator :url="'/pages/suggest/detail?id='+item.id" hover-class="none" class="list"
				v-for="(item,index) in list" :key="index">
			<view class="title flex align between">{{item.title}}
			<view style="color: #CF1A09;font-size: 28rpx;">{{(item.status==1||item.status==4)?'处理中':'已处理'}}</view>
			</view>
			<view class="item flex">
				<view>诉求人</view>
				<view>{{item.realname}}</view>
			</view>
			<view class="item flex">
				<view>联系电话</view>
				<view>{{item.mobile}}</view>
			</view>
			</navigator>
			<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
			<view class="btom-btn">
				<view class="btn" @click="toUrl()">我有建议</view>
			</view>
		</view>
	</view>
</template>
<script>
	import CustomNavbar from '@/components/custom-navbar.vue';
	import {
		problemLists
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				current: 0,
				// tabs: ['未解决', '已解决'],
				tabs: ['待审核', '已通过', '未通过', '处理中', '已反馈'],
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				barHeight: '',
			};
		},
		components: {
			CustomNavbar
		},
		created() {
			const systemInfo = uni.getSystemInfoSync();
			let statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏高度
			let navBarHeight = ''
			if (systemInfo.platform === 'android') {
				navBarHeight = statusBarHeight + 48; // Android 导航栏高度
			} else {
				navBarHeight = statusBarHeight + 44; // iOS 导航栏高度
			}
			this.barHeight = navBarHeight
		},
		onLoad() {},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		onShow() {
			this.status = 'nomore';
			this.scrollTop = 0;
			this.empty = false;
			this.totalPage = 1;
			this.page = 0;
			this.list = [];
			this.getlist();
		},
		methods: {
			toUrl() {
				uni.navigateTo({
					url: '/pages/suggest/suggest'
				})
			},
			changeTab(index) {
				const that = this;
				that.current = index
				this.page = 0
				this.list = []
				this.getlist();
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					current
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await problemLists(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							console.log((888))
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		padding-bottom: 200rpx;
	}

	.btom-btn {
		position: fixed;
		background: white;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.btn {
		background: #FF9008;
		border-radius: 32rpx;
		line-height: 72rpx;
		margin: 50rpx 40rpx;
		text-align: center;
		color: white;
	}

	.list {
		background: white;
		border-radius: 8rpx;
		padding: 15rpx 34rpx;
		margin: 16rpx 24rpx;
	
		.title {
			border-bottom: solid 1rpx #EBEBEB;
			font-size: 32rpx;
			padding-bottom: 16rpx;
		}
	
		.item {
			padding: 16rpx 0;
			font-size: 28rpx;
		}
	
		.item view:nth-child(1) {
			color: #C8C8C8;
			margin-right: 16rpx;
		}
	}
</style>